package com.hu.zhcc.shiro.service.Responsitory;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hu.zhcc.common.entity.Page;
import com.hu.zhcc.shiro.dao.RHealthMapper;
import com.hu.zhcc.shiro.entity.Reponsitory.REvaluate;
import com.hu.zhcc.shiro.entity.Reponsitory.RHealth;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class HealthServiceImpl implements HealthService {

    @Autowired
    private RHealthMapper healthMapper;

    @Override
    public Page<RHealth> healthPage(Map<String, String> map, RHealth health) {
        Integer pageIndex = Integer.valueOf(map.get("pageIndex"));
        Integer num = Integer.valueOf(map.get("num"));
        PageHelper.startPage(pageIndex, num);
        List<RHealth> rHealths = healthMapper.selectAll(health);
        PageInfo<RHealth> pageInfo = new PageInfo<>(rHealths);
        return new Page<RHealth>(pageInfo.getTotal(), rHealths);
    }

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return healthMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insertSelective(RHealth record) {
        return healthMapper.insertSelective(record);
    }

    @Override
    public RHealth selectRHealByid(int id) {
        return healthMapper.selectRHealByid(id);
    }

    @Override
    public int updateByPrimaryKeySelective(RHealth record) {
        return healthMapper.updateByPrimaryKeySelective(record);
    }
}
